/*    
 *    MediathekView
 *    Copyright (C) 2008   W. Xaver
 *    W.Xaver[at]googlemail.com
 *    http://zdfmediathk.sourceforge.net/
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package mediathek.update;

import mediathek.config.Konstanten;
import mediathek.gui.actions.UrlHyperlinkAction;
import mediathek.tool.EscapeKeyHandler;
import net.miginfocom.layout.AC;
import net.miginfocom.layout.CC;
import net.miginfocom.layout.LC;
import net.miginfocom.swing.MigLayout;
import org.jdesktop.swingx.JXHyperlink;

import javax.swing.*;
import java.awt.*;

public class DialogHinweisUpdate extends JDialog {

    public DialogHinweisUpdate(JFrame parent, String ttext) {
        super(parent, true);

        initComponents();

        EscapeKeyHandler.installHandler(this, this::dispose);

        jButtonOk.addActionListener(_ -> dispose());
        jTextArea1.setText(ttext);

        hyperLink.addActionListener(_ -> UrlHyperlinkAction.openURL(Konstanten.ADRESSE_DOWNLOAD));
        pack();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    private void initComponents() {
        var jScrollPane1 = new JScrollPane();
        jTextArea1 = new JTextArea();
        jButtonOk = new JButton();
        hyperLink = new JXHyperlink();

        //======== this ========
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Programminformationen"); //NON-NLS
        setMinimumSize(new Dimension(480, 100));
        var contentPane = getContentPane();
        contentPane.setLayout(new MigLayout(
            new LC().insets("5").hideMode(3).gridGap("5", "5"), //NON-NLS
            // columns
            new AC()
                .grow().fill(),
            // rows
            new AC()
                .grow().fill().gap()
                .fill().gap()
                .fill()));

        //======== jScrollPane1 ========
        {

            //---- jTextArea1 ----
            jTextArea1.setEditable(false);
            jTextArea1.setColumns(20);
            jTextArea1.setLineWrap(true);
            jTextArea1.setRows(5);
            jTextArea1.setText("\n\n"); //NON-NLS
            jTextArea1.setWrapStyleWord(true);
            jTextArea1.setMinimumSize(new Dimension(459, 85));
            jScrollPane1.setViewportView(jTextArea1);
        }
        contentPane.add(jScrollPane1, new CC().cell(0, 0));

        //---- jButtonOk ----
        jButtonOk.setText("Schlie\u00dfen"); //NON-NLS
        contentPane.add(jButtonOk, new CC().cell(0, 2).alignX("right").growX(0)); //NON-NLS

        //---- hyperLink ----
        hyperLink.setText("Link zur Webseite"); //NON-NLS
        contentPane.add(hyperLink, new CC().cell(0, 1));
        pack();
        setLocationRelativeTo(getOwner());
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // Generated using JFormDesigner non-commercial license
    private JTextArea jTextArea1;
    private JButton jButtonOk;
    private JXHyperlink hyperLink;
    // End of variables declaration//GEN-END:variables
}
